package com.fruit.util;


public class PagerContext
{
	/**
	 *分页 升序或者降序字段
	 */
	public static final String ASC="asc";
	public static final String DESC="desc";
	
	/**
	 * 起始页
	 */
	private static ThreadLocal<Integer> currentPage=new ThreadLocal<Integer>();
	/**
	 * 分页大小
	 */
	private static ThreadLocal<Integer> pageSize=new ThreadLocal<Integer>();
	/**
	 * 排序字段
	 */
	private static ThreadLocal<String> sort=new ThreadLocal<String>();
	/**
	 * 排序顺序(ASC|DESC)
	 */
	private static ThreadLocal<String> order=new ThreadLocal<String>();
	
	
	/**
	 * generated by myeclipse blue 10.6
	 * 
	 */
	public static Integer getCurrentPage()
	{
		return currentPage.get();
	}
	public static void setCurrentPage(Integer currentPage)
	{
		PagerContext.currentPage.set(currentPage);
	}
	public static Integer getPageSize()
	{
		Integer pagesize=pageSize.get();
		if(pagesize==null||pagesize<0)
			pagesize=10;
		return pagesize;
	}
	public static void setPageSize(Integer pageSize)
	{
		PagerContext.pageSize.set(pageSize);
	}
	public static String getSort()
	{
		return sort.get();
	}
	public static void setSort(String sort)
	{
		PagerContext.sort.set(sort);
	}
	public static String getOrder()
	{
		return order.get();
	}
	public static void setOrder(String order)
	{
		PagerContext.order.set(order);
	}
	
	public static  void removeCurrentPage()
	{
		PagerContext.currentPage.remove();
	}
	
	public static  void removePageSize()
	{
		PagerContext.pageSize.remove();
	}
	
	public static  void removeSort()
	{
		PagerContext.sort.remove();
	}
	public static  void removeOrder()
	{
		PagerContext.order.remove();
	}
}
